<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>
	<title>Add Branch</title>
</h:head>
<f:view>
	<h:body>
		<ui:composition template="../includes/template.xhtml">
			<ui:define name="mainbody">
				<center>
					<h:form>
						<p:spacer height="5" />

						<p:panel header="Add Branch" style="min-height: 550px"
							styleClass="prime_panel">
							<p:growl id="growl" showDetail="true" sticky="false"
								autoUpdate="true" showSummary="false" />

							<center>
								<table border="0" cellpadding="4px" cellspacing="8px">
									<tr>
										<p:spacer height="20" />

									</tr>

									<tr>
										<td><h:outputText value="School Name: " />
											<h:outputText value="*" style="color:red" />
										</td>
										<td><p:autoComplete value="#{branchBean.selectedSchool}"
												id="school" completeMethod="#{branchBean.completeSchool}"
												var="s" itemLabel="#{s.schoolName}" itemValue="#{s}"
												converter="#{branchBean.schoolConverter}"
												forceSelection="true" size="20" required="true"
												requiredMessage=" Please enter School Name">
												<f:ajax execute="@this" event="blur" />
											</p:autoComplete></td>
										<td><h:outputText value="Branch Name :" />
											<h:outputText value="*" style="color:red" /></td>
										<td><p:inputText size="20" id="branchTitle"
												value="#{branchBean.branch.branchTitle}" required="true"
												requiredMessage="Please enter Branch Title">
												<f:validateLength minimum="3" />
												<f:ajax execute="@this" event="blur" />
											</p:inputText>
										</td>

									</tr>

									<tr>
										<td><h:outputText value="Principal Name :" />
											<h:outputText value="*" style="color:red" /></td>
										<td><p:inputText id="principalName" size="20"
												value="#{branchBean.branch.principalName}" required="true"
												requiredMessage="Please enter Principal Name">
												<f:ajax execute="@this" event="blur" />
											</p:inputText>
										</td>

										<td><h:outputText value="Address :" />
											<h:outputText value="*" style="color:red" />
										</td>
										<td><p:inputText size="20" id="address"
												value="#{branchBean.branch.address}" required="true"
												requiredMessage="Please enter School Address" >
												
												<f:ajax execute="@this" event="blur"/>
												</p:inputText></td>

									</tr>



									<tr>
										<td><h:outputText value="Fax Number:" /></td>
										<td><p:inputMask id="fax" size="20" mask="+99-9999999999"
												value="#{branchBean.branch.faxNumber}" /></td>
												
										<td><h:outputText value="Ph. Number :" />
											<h:outputText value="*" style="color:red" /></td>
										<td><p:inputMask id="ph" mask="+99-9999999999" size="20"
												value="#{branchBean.branch.phoneNumber}" required="true"
												requiredMessage="Please enter School Phone Number" >
												<f:ajax execute="@this" event="blur"/>
												</p:inputMask></td>
									</tr>



									<!-- After this enter the details for branch-admin -->



									<tr>
										<td><b><h:outputLabel value="Admin Details:  "
													style="font-size:18"></h:outputLabel>
										</b></td>
									</tr>

									<tr>
										<td><h:outputText value="Admin Name" />
											<h:outputText value="*" style="color:red" /></td>
										<td><p:inputText id="admin-name"
												value="#{branchBean.user.name}" size="20" required="true"
												requiredMessage="Please enter Admin Name" >
												<f:ajax execute="@this" event="blur"/>
												</p:inputText>
										</td>
										<td><h:outputText value="Admin Email :" />
											<h:outputText value="*" style="color:red" /></td>
										<td><p:inputText id="email"
												value="#{branchBean.user.email}" size="20" required="true"
												requiredMessage="Please enter Admin Email Address"
												validatorMessage="Please enter valid email address">
												<f:validateRegex for="email"
													pattern="^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"></f:validateRegex>
											<f:ajax execute="@this" event="blur"/>
											</p:inputText>
										</td>

									</tr>



									<tr>
										<td><h:outputText value="Password :" />
											<h:outputText value="*" style="color:red" /></td>
										<td><p:password feedback="true" match="password1"
												size="20" id="password"
												validatorMessage="Password should match"
												value="#{branchBean.user.password}" required="true"
												requiredMessage="Please enter Password" >
												<f:ajax execute="@this" event="blur"/>
												</p:password></td>
												
												
										<td><h:outputText value="Re-Enter Password :" />
											<h:outputText value="*" style="color:red" /></td>
										<td><p:password size="20" feedback="false"
												required="true" requiredMessage="Please enter Password"
												id="password1" >
												<f:ajax execute="@this" event="blur"/>
												</p:password></td>
									</tr>



									<tr>
										<td><h:outputText value="Address :" />
											<h:outputText value="*" style="color:red" /></td>
										<td><p:inputText id="admin-address"
												value="#{branchBean.user.address}" size="20" required="true"
												requiredMessage="Please enter Admin Address" >
												<f:ajax execute="@this" event="blur"/>
												</p:inputText></td>
										<td><h:outputText value="Ph. Number :" />
											<h:outputText value="*" style="color:red" /></td>
										<td><p:inputMask id="admin-ph" size="20"
												mask="+99-9999999999" value="#{branchBean.user.phoneNumber}"
												required="true"
												requiredMessage="Please enter Admin Phone Number" >
												<f:ajax execute="@this" event="blur"/>
												</p:inputMask></td>
									</tr>




									<tr>
										<td></td>
										<td></td>
										<td></td>
										<td style="text-align: right"><p:spacer width="5" /> <p:commandButton
												id="submit" ajax="false" value="Submit" type="submit"
												update="growl" action="#{branchBean.action}" />
										</td>
									</tr>
								</table>
							</center>
						</p:panel>
					</h:form>
				</center>
			</ui:define>
		</ui:composition>
	</h:body>
</f:view>
</html>
